<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="stylereg.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/prototype/1.7.0.0/prototype.js"></script>
<script>
    var myRegExp=/^(a-z|A-Z|0-9)*[^#$%^&*;()'<>]*$/;
    Event.observe(window, 'load', function() {

    });
        function strip(str){
        return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
    }
    function register(){
        $('error').innerHTML='';
        var nodes=$('form').getInputs('text');
        var passwords=$('form').getInputs('password');
        if(passwords[0].value!=passwords[1].value){
            $('error').update('*password dont match');
            return;
        }
        if(nodes[0].value=='' || nodes[1].value=='' ||passwords[0].value==''){
            $('error').update('*fill all fields');
            return;
        }
        if(!myRegExp.test(nodes[0].value) || !myRegExp.test(nodes[1].value)|| !myRegExp.test(passwords[0].value)){
            $('error').update("*De volgende tekens zijn niet toegestaan: #$%^&*();'<>");
            return;
        }
        new Ajax.Request('Ajax.php',{
           method:'post',
           parameters:{register:nodes[0].value,password:passwords[0].value,email:nodes[1].value},
           onSuccess:evaluate
        });
    }
    function evaluate(data){
        var response=data.responseText;
        if(!strip(response)){
            window.location="index.php";
        }
        $('error').update(response);
    }
</script>
<title>Register to IMP</title>
</head>

<body>





<form class="contact_form" method="post" action="javascript:register();" id="form">

<ul>
	
  	<li>
    	<span id="text">Register</span>
    	<input  type="text" name="user" placeholder="Username"/>
    </li>
    <li>
    	<input  type="text" name="email" placeholder="Email"/>
    </li>
   	<li>
   		 <input  type="password" name="password" placeholder="Password" />
   	</li>
    	<li>
   		 <input  type="password" name="password" placeholder="Repeat Password" />
   	</li>
    <li>
    	
        <button class="submit" type="submit" id='submit'>Registreer</button><br/>
        <span id="error"></span>
    </li>
</ul>
</form>





</body>
</html>
